﻿<!DOCTYPE HTML>
<html lang="zh">
<head>
<title>MonitorGet - 语法 &amp; 使用 | AutoHotkey v2</title>
<meta name="description" content="The MonitorGet function checks if the specified monitor exists and optionally retrieves its bounding coordinates." />
<meta name="ahk:equiv-v1" content="lib/SysGet.htm#Monitor" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>MonitorGet</h1>

<p>检查指定的监视器是否存在, 并可选地检索其边界坐标.</p>

<pre class="Syntax">ActualN := <span class="func">MonitorGet</span>(<span class="optional">N, &amp;Left, &amp;Top, &amp;Right, &amp;Bottom</span>)</pre>

<h2 id="Parameters">参数</h2>
<dl>
    <dt>N</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
        <p>监视器编号, 介于 1 和 <a href="MonitorGetCount.htm">MonitorGetCount</a> 返回的数字之间. 如果省略, 则使用主监视器.</p>
    </dd>
    
    <dt>&amp;Left</dt>
    <dt>&amp;Top</dt>
    <dt>&amp;Right</dt>
    <dt>&amp;Bottom</dt>
    <dd>
        <p>类型: <a href="../Concepts.htm#variable-references">VarRef</a></p>
        <p>储存边界坐标(以像素为单位) 的变量的引用.</p>
    </dd>
</dl>

<h2 id="Return_Value">返回值</h2>
<p>类型: <a href="../Concepts.htm#numbers">整数</a></p>
<p>该函数返回显示器编号(与 N 相同, 除非省略 N).</p>

<h2 id="Error_Handling">错误处理</h2>
<p>失败时抛出异常, 输出变量不会被修改.</p>

<h2 id="Remarks">备注</h2>
<p>内置变量 <a href="../Variables.htm#Screen">A_ScreenWidth</a> 和 <a href="../Variables.htm#Screen">A_ScreenHeight</a> 包含主监视器的尺寸(以像素为单位).</p>
<p>可以使用 <a href="SysGet.htm">SysGet</a> 检索所有显示监视器的边框. 例如, 它检索虚拟屏幕的宽度和高度:</p>
<pre>MsgBox SysGet(78) " x " SysGet(79)</pre>

<h2 id="Related">相关</h2>
<p><a href="MonitorGetWorkArea.htm">MonitorGetWorkArea</a>, <a href="SysGet.htm">SysGet</a>, <a href="Monitor.htm">监视器函数</a></p>

<h2 id="Examples">示例</h2>
<div class="ex" id="ExBasic">
<p><a class="ex_number" href="#ExBasic"></a> 在消息框中显示监视器 #2 的边界坐标.</p>
<pre>
<pre>try
{
    MonitorGet 2, &amp;Left, &amp;Top, &amp;Right, &amp;Bottom
    MsgBox "Left: " Left " -- Top: " Top " -- Right: " Right " -- Bottom: " Bottom
}
catch
    MsgBox "Monitor 2 doesn't exist or an error occurred."</pre>
</div>

<p>有关此函数的演示, 请参阅<a href="Monitor.htm">监视器函数</a>页面的<a href="Monitor.htm#ExLoopAll">示例 #1</a>.</p>

</body>
</html>